package dao.factory;

import dao.WarehouseDao;
import dao.CargoDao;
import dao.UserDao;
import dao.impl.WarehouseDaoImpl;
import dao.impl.CargoImpl;
import dao.impl.UserDaoImpl;

public class DaoFactory {
	
	private static UserDao userDao;
	
	private static WarehouseDao warehouseDao;
	
	private static CargoDao cargoDao;
	
	public static UserDao getInstance(){
		if (userDao==null) {
			synchronized (DaoFactory.class) {
				if (userDao==null) {
					userDao = new UserDaoImpl();
				}
			}
		}
		return userDao;
	}
	
	public static WarehouseDao getWarehouseDaoInstance(){
		if (warehouseDao==null) {
			synchronized (DaoFactory.class) {
				if (warehouseDao==null) {
					warehouseDao = new WarehouseDaoImpl();
				}
			}
		}
		return warehouseDao;
	}
	
	public static CargoDao getCargoDaoInstance(){
		if (cargoDao==null) {
			synchronized (DaoFactory.class) {
				if (cargoDao==null) {
					cargoDao = new CargoImpl();
				}
			}
		}
		return cargoDao;
	}

}
